//logs.js
var app = getApp();
import Api from '../../../api/api.js';
const api = new Api();
Page({
  data: {
    pageIndex: 1,
    pageCount: 10,
    dataList: [],
    isEmpty: false,


  },
  onLoad: function () {
    this.getListData();
  },
  onShow() {
  },
  getListData() {
    var _this = this;
    var map = {};
    map.userId = app.USER_ID();
    map.pageCount = this.data.pageCount;
    map.pageIndex = this.data.pageIndex;
    api.getRequestData(app.mineBFJiDiListUrl, map, true, "POST").then(res => {
      if (res.data.errorCode == 0) {
        var list = res.data.model.list;

        console.log("=======>>>>>>",JSON.stringify(list));
        if (list.length == 0) {
          app.alert("没有更多数据了～");
        }
        if (_this.data.pageIndex == 1) {
          _this.data.dataList = list;
          _this.setData({
            dataList: _this.data.dataList
          });
        } else {
          // 加载更多
          _this.setData({
            dataList: _this.data.dataList.concat(list)
          });
        }
        if (_this.data.dataList.length == 0) {
          _this.setData({
            isEmpty: true
          });
        } else {
          _this.setData({
            isEmpty: false
          });
        }
      } else {
        wx.showToast({
          title: res.data.errorMsg,
          icon: 'none',
          duration: 1500
        });
      }
    });
  },
  itemClick(e) {
    var key = e.currentTarget.dataset.key;
    wx.navigateTo({
      url: '/pages/mine/bangfuDetail/bangfuDetail?basesId=' + key,
    })
  },
  bangFuClick() {

  },
  onPullDownRefresh: function () {
    this.data.pageIndex = 1;
    this.getListData();

  },
  updatePerViewimage(e) {
    var ids = e.currentTarget.dataset.key + "";
    var idsArr = ids.split("_");
    var index = idsArr[0];
    var dict = this.data.dataList[index];
    var imgs = dict.imgs;
    index = idsArr[1];
    var url = imgs[index];
    wx.previewImage({
      current: url,
      urls: imgs,
    })
  },
  lookDongTai(e){
    var id = e.currentTarget.dataset.key;
    wx.navigateTo({
      url: '/pages/mine/minebangfu/dongTai?basesId=' + id,
    })
  },
  /**
   * 页面上拉触底事件的处理函数/
   */
  onReachBottom: function () {
    this.data.pageIndex += 1;
    this.getListData();
  },

})
